package vn.fpt.fsoft.autotest.userDAO;

import vn.fpt.fsoft.dao.UserDAO;
import vn.fpt.fsoft.autotest.database.DBWithNoRow;
import vn.fpt.fsoft.autotest.database.UserDBWithOneRows;
import vn.fpt.fsoft.entity.User;
import static org.junit.Assert.*;

import org.junit.Test;

public class AddUser {

    public User user = new User();
    
    @Test
    public void testCase1() {
        DBWithNoRow.CreateData();
        UserDAO dao = new UserDAO();
        user.setUsername("username1");
        user.setPassword("password1");
        user.setEmail("email1@gmail.com");
        user.setRole(1);
        user.setActive(true);
        
        assertEquals(true, dao.addUser(user));
    }
    
    @Test
    public void testCase2() {
        UserDBWithOneRows.CreateData();
        UserDAO dao = new UserDAO();
        user.setUsername("USERNAME1");
        user.setPassword("password1");
        user.setEmail("email1@gmail.com");
        user.setRole(1);    
        user.setActive(true);
        
        assertEquals(false, dao.addUser(user));
    }

}
